package com.baihan.angus.app.game.busshow.adps;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;

import com.baihan.angus.app.game.basic.utils.ComUtil;
import com.baihan.angus.app.game.basic.views.mzbanner.holder.MZViewHolder;
import com.baihan.angus.app.game.busshow.R;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.qmuiteam.qmui.widget.QMUIRadiusImageView;

public class BannerViewHolder implements MZViewHolder<String> {

    private Context mContext;
    private QMUIRadiusImageView mImageView;

    @Override
    public View createView(Context context) {
        mContext = context;
        View view = LayoutInflater.from(context).inflate(R.layout.item_banner, null);
        mImageView = view.findViewById(R.id.iv);
        return view;
    }

    @Override
    public void onBind(Context context, int position, String data) {
        //设置图片圆角角度
        RoundedCorners roundedCorners= new RoundedCorners(ComUtil.Dp2Px(context,8));
        Glide.with(mContext).load(data)
                .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.AUTOMATIC))
                .apply(RequestOptions.bitmapTransform(roundedCorners)).into(mImageView);
    }
}
